<!DOCTYPE html>
<html>
<head>
	<include file="Public:common-css" />
	<link type="text/css" rel="stylesheet" href="__ICSS__/login.css" />
</head>
<body>
<div class="container">
<!-------------------------header--------------------------------->
<include file="Public:header2" />
<!-------------------------header-end----------------------------->
<div class="clr"></div>
<!--------------------------content------------------------------->
	<div class="lr-box">
    	<div class="login-content">
        	<div class="login-ad"><img src="__IIMG__/login-ad.jpg"/></div>
        	<div class="login-wrap">
	            <div class="login">
	            	<form action="<{:U('Login/registerUser')}>" method="post" class="registerForm">
	                	<div class="login-t"><a href="__ROOT__/Login">登录</a> | <span>注册</span></div>
	                    <p class="message" style="display:none;"></p>
	                    <p class="check-success"><input type="text" class="l-input phonenum" placeholder="请输入手机号"  nullmsg="请填写您的手机号码" sucmsg="可以使用" name="tel" datatype="e" ajaxurl="__URL__/checkTel" sucmsg="手机号还未被使用，可以注册！"/><b class="phone-icon"></b></p>
	                    <p class="check-success tel-code-box">
	                    	<input type="text" class="l-input phone-code-input" id="tel_code" placeholder="验证码" name="tel_code" datatype="e" nullmsg="请输入手机验证码" />
	                    	<input type="button" id="phone-btn" class="phone-code-button" value="获取手机验证码"/><em id="em_code" class="em-code-success"></em>
	                    	<b class="referrer-icon"></b>
	                    </p>
	                    <p class="check-success"><input type="password" class="l-input password1" placeholder="请输入密码(6-20位英文数字)" nullmsg="请输入密码(6-20位英文数字)" sucmsg="可以使用" name="password"/><b class="password-icon"></b></p>
	                    <p class="check-success"><input type="password" class="l-input password2" placeholder="确认密码" nullmsg="请确认密码" sucmsg="通过验证" name="password2"/><b class="password-icon"></b></p>
	                    <p class="check-success"><input type="text" class="l-input" placeholder="请输入推荐人的ID" name="parent_id"/><b class="user-name-icon"></b></p>
	                    <p><input type="submit" id="btn" value="立即注册" class="submit-btn register-btn"/></p>
	                    <button type="reset" id="reset2" style="display:none;" class="btn btn-success btn-block">重置</button>
	                </form>
	                <div class="clearfix"></div>
	            </div>
            </div>
        </div>
        <div class="clr"></div>
    </div>
<!--------------------------content-end--------------------------->
    <include file="Public:footer" />
</div>

</body>
<include file="Public:common-js" />
<script type="text/javascript" src="__IJS__/Validform_v5.3.2_min.js" ></script>
<script type="text/javascript">
$(function(){
	initAdSize();
	$(window).resize(function () {
		initAdSize();
	});
	window.onload = function(){
		initAdSize();
	}
	function initAdSize() {
		var width = $(".login-content").width() - $(".login-wrap").width();
		$(".login-ad").width(width);
		if($(".login-box").width() == 1080) {
			$(".login-ad").find("img").width(width * 0.7);
		}else if($(".login-box").width() == 980) {
			$(".login-ad").find("img").width(width * 0.9);
		}
		var loginWrapHeight = $(".login-wrap").height();
		var imgHeight = $(".login-ad").find("img").height();
		if(imgHeight < loginWrapHeight) {
			$(".login-ad").find("img").css("margin-top",(loginWrapHeight - imgHeight  - 90)/2);
		}else{
			$(".login-ad").find("img").css("margin-top",0);
		}
	}
	
	$(".register-btn").click(function (){
		if(!testSpace($(".phonenum").val())){
			layer.msg("手机号码中含有空格字符，请重新检查");
			$('input[name="tel"]').focus();
			return false;
		}
		function testSpace(str){
			if(str.indexOf(" ") >= 0){
				return false;
			}else{
				return true;
			}
		}
	})
	$("#reset2").click();
	//表单验证
	var form=$(".registerForm").Validform({
		btnSubmit:".register-btn", 
		tiptype:4,
		label:".label",
		showAllError:false,
		postonce:true,
		datatype:{
			"p6-20":/^[a-z0-9A-Z]{6,20}$/
			
		},
		ajaxPost:true,
		callback:function(data){
			if(data.status == 1){
				layer.alert(data.info);
				window.location.href = "__ROOT__"
			}else{
				layer.alert(data.info);
			}
		}
	});
	form.tipmsg.w["p6-20"]="密码格式为6到20位英文数字！";
	form.addRule([{
		ele:".phonenum",
		datatype:"m"
	},
	{
		ele:".phone-code-input",
		datatype:"s6-6"	
	},
	{
		ele:".password1",
		datatype:"p6-20"
	},
	{
		ele:".password2",
		datatype:"p6-20",
		recheck:"password"
	}]);
	$("#reflesh").click(function(){
		fleshVerify();
	})
	
		
	//发送成功请等待 
	$("#phone-btn").click(function() {
		var telIpt = $('input[name="tel"]');
		//判断手机是否验证通过
		if($(".registerForm").Validform().check(true,telIpt) && telIpt.Validform().eq(0).forms[0].validform_valid == "true"){
			$.ajax({
				url:"__ROOT__/Login/sendPhoneCode",
				type:"post",
				data:{tel:telIpt.val()},
				success:function(data){
					if(data.status == 1){
						$("#em_code").attr("class","em-code-error");
						$("#em_code").html(data.info);
					}else{
						$("#em_code").attr("class","em-code-success");
						$("#em_code").html("");
					}
				}
			})
			countDown(this);
		}else{
			layer.msg("手机号格式不正确或已被注册!");
			
		}
	});

})
//倒计时
var wait= 60;
function countDown(t){
	if (wait == 0) {
		$("#phone-btn").attr("class","phone-code-button");
		t.removeAttribute("disabled");			
		t.value="获取手机验证码";
		wait = 60;
	} else {
		t.setAttribute("disabled", true);
		$("#phone-btn").attr("class","phone-code-button-off");
		t.value="重新发送(" + wait + ")";
		wait--;
		setTimeout(function() {
			countDown(t)
		},1000)
	}
}

</script>

</html>
